home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / jazlib.arc / JAZ.H < prev    next >
Text File  |  1988-12-18  |  6KB  |  223 lines

  1. /*
  2. ┌────────────────────────────────────────────────────────────────────────────┐
  3. │ Title   : jaz.h                                 │
  4. │ Purpose : Define general purpose macros for use in my programs         │
  5. │                                         │
  6. │    Written by Jack Zucker - 75766,1336    301-794-5950  on 1/15/85      │
  7. └────────────────────────────────────────────────────────────────────────────┘
  8. */
  9.  
  10. /* given a segment and offset, return a pointer which will point to the */
  11. /* seg:off pair                             */
  12.  
  13. #define LPOINTER(type,seg,ofs) (type far *) ((long) seg << 16 | ofs)
  14. #define CNULL 0
  15. #define SEG(x) *((unsigned*)&(x)+1)
  16. #define OFS(x) *((unsigned*)&(x))
  17. #define msdos(_wreg) intr(0x21,_wreg)    /* define turbo like msdos call */
  18. #define lobyte(a) *((unsigned char *)&(a))
  19. #define hibyte(a) *((unsigned char *)&(a)+1)
  20. #define loword(a) *((unsigned *)&(a))
  21. #define hiword(a) *((unsigned *)&(a)+1)
  22. #define max(x,y) (x > y ? x : y)
  23. #define min(x,y) (x < y ? x : y)
  24.  
  25.  
  26. /* ──────────────── define various memory peek macros. ──────────────── */
  27.  
  28. /* this one returns a char */
  29. #define MEMB(seg,ofs) (*LPOINTER(unsigned char,seg,ofs))
  30.  
  31. /* this one returns a word */
  32. #define MEMW(seg,ofs) (*LPOINTER(unsigned int,seg,ofs))
  33.  
  34. #define MEML(seg,ofs) (*LPOINTER(long,seg,ofs))
  35. /* this one returns a long */
  36.  
  37. /* ──────────────── define a macro for avoiding snow.  ──────────────── */
  38.  
  39. /* this next macro will wait for the horizontal retrace status bit to */
  40. /* avoid snow. Much more elegant than writing the routines in masm    */
  41.  
  42. #define WAITSCR while (inp(0x3da) & 1) ; while (! (inp(0x3da) & 1)) ;
  43.  
  44. struct tfat {
  45.   long        free;
  46.   long        total;
  47.   long        used;
  48. } ;
  49. #define TFAT struct tfat
  50.  
  51. /* structure for keyboard shift state */
  52. struct shiftstate {
  53.   unsigned rightshift : 1;
  54.   unsigned leftshift  : 1;
  55.   unsigned control    : 1;
  56.   unsigned alt          : 1;
  57.   unsigned scroll     : 1;
  58.   unsigned numlock    : 1;
  59.   unsigned capslock   : 1;
  60.   unsigned insert     : 1;
  61. };
  62. #define SHIFTSTATE struct shiftstate
  63.  
  64. /* structure for keyboard hold state */
  65. /* this byte indicates whether or not the key is being pressed, not the state */
  66. struct holdstate {
  67.   unsigned filler     : 2;
  68.   unsigned pcjrclick  : 1;
  69.   unsigned ctrlnum    : 1;
  70.   unsigned scroll     : 1;
  71.   unsigned numlock    : 1;
  72.   unsigned capslock   : 1;
  73.   unsigned insert     : 1;
  74. };
  75. #define HOLDSTATE struct holdstate
  76.  
  77. union keystate {
  78.   HOLDSTATE   h;
  79.   SHIFTSTATE  s;
  80. };
  81. #define KEYSTATE union keystate
  82.  
  83. struct REGW {
  84.   unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  85. };
  86.  
  87. struct REGB {
  88.   unsigned char al,ah,bl,bh,cl,ch,dl,dh;
  89. };
  90.  
  91. union TREG {
  92.   struct REGW x;
  93.   struct REGB h;
  94. };
  95.  
  96. struct tname {
  97.   char *filename;
  98.   struct tname *next;
  99. };
  100. #define TNAME struct tname
  101.  
  102. struct tdiskblk {
  103.   char jmploc[3];    /* code to jump to boot rec */
  104.   char sysid[8];    /* system id */
  105.   int  bytes;        /* bytes per sector */
  106.   char sectors;     /* sectors per cluster */
  107.   int rsvsect;        /* number of reserved sectors */
  108.   char numfat;        /* num of fat tables */
  109.   int numdir;        /* num of root dir entries */
  110.   unsigned int ttlsect; /* total sectors on disk */
  111.   char fmtid;        /* format id */
  112.   int sectfat;        /* num of sectors per fat */
  113.   int secttrack;    /* num of sectors per track */
  114.   int numheads;     /* num of heads (sides) */
  115.   int special;        /* special reserved sectors */
  116. };
  117. #define TDISKBLK struct tdiskblk
  118.  
  119. struct tdiskdir {
  120.     char filename[8];
  121.     char ext[3];
  122.     unsigned char attribute;
  123.     char reserved[10];
  124.     unsigned int time;
  125.     unsigned int date;
  126.     unsigned int cluster;
  127.     long size;
  128.   };
  129. #define TDISKDIR struct tdiskdir
  130.  
  131. struct tfcb {
  132.   char flag ;
  133.   char junk[5];
  134.   char search;
  135.   char drive;
  136.   char name[8];
  137.   char ext[3];
  138.   char attr;
  139.   char dos[10];
  140.   int time;
  141.   int date;
  142.   int cluster;
  143.   long size;
  144. };
  145. #define TFCB struct tfcb
  146.  
  147. struct tbit {
  148.   unsigned b : 1;
  149. };
  150.  
  151. struct tbitmap {
  152.   struct tbit bit[8];
  153. };
  154. #define TBITMAP struct tbitmap
  155.  
  156. struct thead {
  157.   int listlen;
  158.   struct tname *first,*last;
  159. };
  160. #define THEAD struct thead
  161.  
  162.  
  163. THEAD *rsplist();
  164. THEAD *dirlist();
  165.  
  166. struct tregx {            /* define a register struct for bios calls */
  167.   unsigned int ax,bx,cx,dx,si,di,ds,es,flags;
  168. };
  169.  
  170. struct tregh {
  171.   unsigned char al,ah,bl,bh,cl,ch,dl,dh;
  172. };
  173.  
  174. struct tstack                /* stack structure for pushdir/popdir*/
  175. {
  176.   char *pointer;            /* pointer to path name */
  177.   int wint;                /* generic integer */
  178.   struct tstack *next,*prev;
  179. };
  180. #define TSTACK struct tstack
  181.  
  182. struct tstkhead
  183. {                    /* head of stack struct */
  184.   int numitems;             /* size of stack items    */
  185.   struct tstack *first , *last;      /* pointer to items in stack */
  186. };
  187. #define TSTKHEAD struct tstkhead
  188.  
  189. union treg {
  190.   struct tregx x;
  191.   struct tregh h;
  192. };
  193. #define TREG union treg
  194.  
  195. struct tvector { unsigned int offset,segment; };
  196. #define TVECTOR struct tvector
  197.  
  198. #if LINT_ARGS
  199. /*global*/  void intr(int , TREG *);
  200. /*global*/  int rindex(char *,char);
  201. /*global*/ char *tabtosp(char *,char *);
  202. /*global*/ void jzdskfre(TFAT *,int);
  203. /*global*/ char *jzpad(int , int);
  204. /*global*/ void jzgetint(int,TVECTOR *);
  205. /*global*/ int jzinstr(char*,int,int,int,int,long,char*);
  206. /*global*/ char *jzrgtjst(char *,int);
  207. /*global*/ void jzdelay(long);
  208. /*global*/ char *jzstrpos(char *,char*);
  209. /*global*/  unsigned char far *jzfat(int ,int  *,int  *,int  *);
  210. /*global*/  void jzgetfat(char **, int);
  211. /*global*/  unsigned int jzgetcls( char *, int , int);
  212. /*global*/  int jzfateof( unsigned int , int );
  213. /*global*/ char *jzcntstr( char * , int );
  214. /*global*/ char *jzrgtstr(char * , int);
  215. /*global*/ char *jzlftstr(char *,int);
  216. /*global*/ char *jzmidstr(char *,int , int);
  217. /*global*/ int jzcrtfil( char * , int);
  218. /*global*/ int jzredfil(int , char * , int);
  219. /*global*/ int jzwrtfil(int , char * , int);
  220. /*global*/ long jzsekfil(int , unsigned long , int);
  221. #endif
  222.  
  223.